#include <iostream>
using namespace std;

typedef struct S
{
	int score;
	string name;
	
}S;


int main()
{
	int n;
	cin >> n;
	S max;
	cin >> max.score >> max.name;
	n--;
	S s;
	while(n--)
	{
		cin >> s.score >> s.name;
		if(s.score > max.score)
		{
			max.score = s.score;
			max.name = s.name;
		}
	}
	cout << max.name << endl;
	return 0;
}
